﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Ionic.Zlib;

class Ziping
{
    private const string InputFileName = @"..\..\file.txt";
    private const string OutputFileName = @"..\..\file.zip";
    private const int BUFF_SIZE = 4096;

    static void Main(string[] args)
    {
        FileStream inputFile = new FileStream(InputFileName, FileMode.Open, FileAccess.Read);
        FileStream outputFile = new FileStream(OutputFileName, FileMode.OpenOrCreate, FileAccess.Write);
        ZlibStream zs = new ZlibStream(outputFile, CompressionMode.Compress);
        zs.BeginWrite(null,0,0,null,null);
        while (inputFile.Position < inputFile.Length)
        {
            byte[] line = new byte[BUFF_SIZE];
            inputFile.Read(line, 0, BUFF_SIZE);
            zs.Write(line,0,BUFF_SIZE);
        }

        zs.Close();
        inputFile.Close();
        outputFile.Close();
    }
}
